home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
getuse.arc
/
GETUSER.C
Wrap
Text File
|
1988-02-06
|
6KB
|
207 lines
/**********************************************************************
** GETUSER Get Network User ID (Login Name) **
** **
** Program: Commercial Loan System (CLS) **
** Module: GETUSER.C **
** Date: March 26, 1987 **
** Developer: GLENFED Financial Corporation **
** Programmer: Thomas E. Scribner **
** Compile: Small Model **
** Children: **
** Link: **
** **
** Description: This function is the Novell Network Log Function **
** E3h (16h) - Get a Connection's Information. This **
** call retrieves an object's log record from the **
** network and returns it to the calling station. **
** **
** History: **
** 11/23/87 tes Mod to allow function to return UNKNOWN when the **
** network shell is loaded and user is not logged **
** into the network. **
** **
** 07/09/87 TES Mod getname so that when not on net returns **
** UNKNOWN user name. **
** **
** (c)1987, GLENFED Financial Corporation **
** All Rights Reserved. **
**********************************************************************/
#define LINT_ARGS
#include <stdio.h>
#include <dos.h>
#include <string.h>
/*
** Novell Data Types
*/
typedef unsigned char BYTE;
typedef unsigned int WORD,NATIVE;
typedef unsigned long LONG;
/*
** Request Packet Definition
*/
typedef struct {
NATIVE PacketLength;
BYTE Function;
BYTE ConnectionNumber;
}REQUESTPAK;
typedef REQUESTPAK far * lpREQUESTPAK;
/*
** Reply Packet Definition
*/
typedef struct {
NATIVE ReturnLength;
LONG UniqueID;
WORD Type;
BYTE ObjectName[48];
BYTE LogTime[8];
}REPLYPAK;
typedef REPLYPAK far * lpREPLYPAK;
unsigned char GetConnection( void );
#define ERROR -1
#define SUCCESS 0
/*-----------------------------------------------------------------*/
/* SendPacket Make the Novell Function call with the Request */
/* and Reply Packet. */
/*-----------------------------------------------------------------*/
#ifdef MSC4
SendPacket(lpRequest,lpReply)
lpREQUESTPAK lpRequest;
lpREPLYPAK lpReply;
#else
SendPacket( lpREQUESTPAK lpRequest, lpREPLYPAK lpReply )
#endif
{
union REGS regs;
struct SREGS segregs;
int ret;
/*
** DS:SI - Address of Request Buffer
*/
segregs.ds = FP_SEG( lpRequest );
regs.x.si = FP_OFF( lpRequest );
/*
** ES:DI - Address of Reply Buffer
*/
segregs.es = FP_SEG( lpReply );
regs.x.di = FP_OFF( lpReply );
regs.h.ah = 0xE3; /* Function E3h - Get a */
ret = intdosx(®s,®s,&segregs); /* Int 21h */
return(regs.h.al);
}
/*-----------------------------------------------------------------*/
/* GetConnection - Get Connection is used to return the logical */
/* port number of the file server to which the */
/* station is connected. */
/*-----------------------------------------------------------------*/
unsigned char
GetConnection()
{
union REGS inregs,outregs;
inregs.h.ah = 0xDC;
intdos(&inregs,&outregs);
return(outregs.h.al);
}
/*-----------------------------------------------------------------*/
/* GetName This function builds the request and reply */
/* packet for the SendPacket function. It places */
/* the User Name in the username passed to it. */
/*-----------------------------------------------------------------*/
int
#ifdef MSC4
GetName(UName)
char *UName;
#else
GetName( char *UName )
#endif
{
REQUESTPAK Packet1;
REPLYPAK Packet2;
int ret_code;
ret_code = SUCCESS;
Packet1.PacketLength = 2;
Packet1.Function = 0x16;
Packet1.ConnectionNumber = (BYTE)GetConnection();
if(Packet1.ConnectionNumber == 0){
strcpy(UName,"UNKNOWN");
}else{
Packet2.ReturnLength = 62;
ret_code = SendPacket((lpREQUESTPAK)&Packet1,(lpREPLYPAK)&Packet2);
if( ret_code != SUCCESS)
strcpy(UName,"UNKNOWN");
else
strcpy(UName,Packet2.ObjectName);
}
return(ret_code);
}
/*
#ifdef DEBUG
void
main(argc,argv)
int argc;
char *argv[];
{
char TEST[25];
GetName(TEST);
printf("The users name is %s",TEST);
}
#endif
*/
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */
/* --- END OF FILE --- END OF FILE --- END OF FILE --- END OF FILE --- */